var Helloworld = cc.Layer.extend({
    isMouseDown: false,
    isKeyDown: true,

    init: function() {
        var selfPointer = this;

        this._super();

        var winsize = cc.Director.getInstance().getWinSize();

        var tree = dino.create('tree');
        tree.setPosition(cc.p(winsize.width / 2, winsize.height / 2))
        this.addChild(tree);
      
        tree.changeStatus('create');

//        test.call(this);

        return true;

        function test() {
            var sprite = cc.Sprite.create("res/images/chris.png", new cc.Rect(0, 0, 48, 64));
            sprite.setTag("test");
            var shipTexture = cc.TextureCache.getInstance().addImage("res/images/chris.png");
            // set frame
            var frame0 = cc.SpriteFrame.createWithTexture(shipTexture, cc.rect(0, 0, 48, 64));
            var frame1 = cc.SpriteFrame.createWithTexture(shipTexture, cc.rect(48, 0, 48, 64));

            var animFrames = [];
            animFrames.push(frame0);
            animFrames.push(frame1);

            // ship animate
            var animation = cc.Animation.create(animFrames, 0.1);
            var animate = cc.Animate.create(animation);
            var rpt = cc.RepeatForever.create(animate);
            console.log('rpt', rpt);
            sprite.runAction(rpt);
            sprite.setPosition(cc.p(160, 160));
            this.addChild(sprite);
        }
    }

});
var HelloWorldScene = cc.Scene.extend({
    onEnter: function() {
        this._super();
        var layer = new Helloworld();
        layer.init();
        this.addChild(layer);
    }
});